package com.yc;

import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

/**
 * @author zwei
 * @create 2024-08-11 15:11
 */
@Configuration
public class VelocityConfig {
    @Bean
    public VelocityEngine velocityEngine() {
        VelocityEngine velocityEngine = new VelocityEngine();
        velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
        velocityEngine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
        velocityEngine.init();
        return velocityEngine;
    }
    @Bean
    public VelocityContext velocityContext(){
        return new VelocityContext();
    }
    @Bean
    public Template depositTemplate(@Autowired VelocityEngine velocityEngine){
        return velocityEngine.getTemplate("vms/deposite.vm","utf-8");
    }
    @Bean
    public Template withdrawTemplate(@Autowired VelocityEngine velocityEngine){
        return velocityEngine.getTemplate("vms/withdraw.vm","utf-8");
    }
    @Bean
    public Template transferTemplate(@Autowired VelocityEngine velocityEngine){
        return velocityEngine.getTemplate("vms/transfer.vm","utf-8");
    }
    @Bean
    public DateFormat fullDf(){
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    }
    @Bean
    public DateFormat partDf(){
        return new SimpleDateFormat("北京时间:yyyy-MM-dd HH:mm:ss");
    }
}
